/**
 * 对后端接口返回的数据进行处理
 */
const handle = require("../hooks/index");
// 日历页面中,返回的数据进行处理
export function handleCalendar(data:FormData[]):{ [key: number]: FormData[][] } {
  let temp:FormData[][] = []
  for(let i = 0; i < data.length; i++) {
    temp = handle.processData(data[i], temp)
  }
  const grouped = temp.reduce((acc, items) => {
    const areaId = items[0].exerciseAreaId;
    if (!acc[areaId]) {
      acc[areaId] = [];
    }
    acc[areaId].push(items);
    return acc;
  }, {} as Record<number, FormData[][]>);

  return grouped;
}